package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.mapper.SetmealMapper;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.net.InetAddress;
import java.util.List;

@RestController
@RequestMapping("/admin/setmeal")
@Api(tags = "套餐相关接口")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    @ApiOperation("新增套餐")
    @PostMapping
    public Result save(@RequestBody SetmealDTO dto){
        return setmealService.save(dto);
    }

    @ApiOperation("条件分页查询")
    @GetMapping("/page")
    public Result queryByPage(SetmealPageQueryDTO dto){
        return setmealService.queryByPage(dto);
    }

    @ApiOperation("批量删除套餐")
    @DeleteMapping
    public Result deleteByIds(@RequestParam List<Long> ids){
        return setmealService.deleteByIds(ids);
    }

    @ApiOperation("根据id查询菜品")
    @GetMapping("/{id}")
    public Result selectById(@PathVariable Long id){
        return setmealService.selectById(id);
    }

    @ApiOperation("修改套餐")
    @PutMapping
    public Result update(@RequestBody SetmealDTO dto){
        return setmealService.update(dto);
    }

    @ApiOperation("套餐起售停售")
    @PostMapping("/status/{status}")
    public Result startOrStop(@PathVariable Integer status,Long id){
        return setmealService.startOrStop(status,id);
    }
}
